package chapter06

object Test05_Constructor {
  def main(args: Array[String]): Unit = {
    val teacher = new Teacher()
    teacher.Teacher()
    println("==================================================")
    val teacher1 = new Teacher("alice")
    println("==================================================")
    val teacher2 = new Teacher("bob", 35)
  }
}

class Teacher {
  //定义属性
  var name: String = _
  var age: Int = _
  println("1 主构造方法被调用")

  def this(name: String) {
    this()
    println("2. 辅助构造方法一被调用")
    this.name = name
    println(s"name: ${name},age: ${age}")
  }

  def this(name: String, age: Int) {
    this(name)
    println("3. 辅助构造方法二被调用")
    this.age = age
    println(s"name: ${name},age: ${age}")
  }

  def Teacher() = println("不是构造方法而是一个普通方法被调用")


}
